<template>
	<!-- 每个主题类型项 -->
	<view class="theme-item">
		<!-- 通过分类id进入classlist -->
		<navigator :url="`/pages/classlist/classlist?id=`+item._id+`&name=`+item.name+`&type=classid`" class="box"
			v-if="!isMore">
			<image class="img" :src="item.picurl" mode="aspectFill"></image>
			<view class="mask">{{item.name}}</view>
			<view class="tab">{{updateTime}}前更新</view>
		</navigator>

		<navigator url="/pages/classify/classify" open-type="reLaunch" class="box more" v-if="isMore">
			<image class="img" src="/common/img/more.jpg" mode="aspectFill"></image>
			<view class="mask">
				<uni-icons type="more-filled" size="34" color="#fff"></uni-icons>
				<view class="text">更多</view>
			</view>
		</navigator>
	</view>
</template>

<script setup>
	import {
		computed
	} from 'vue';
	import {
		compareTimestamp
	} from '../../utils/time';

	const props = defineProps({
		isMore: {
			type: Boolean,
			default: false
		},
		item: {
			type: Object
		}
	})
	const updateTime = computed(() => {
		return compareTimestamp(props.item.updateTime)
	})
</script>

<style lang="scss" scoped>
	.theme-item {
		.box {
			height: 340rpx;
			border-radius: 10rpx;
			overflow: hidden;
			position: relative; //让子集以父定位

			.img {
				width: 100%;
				height: 100%;
			}

			.mask {
				width: 100%;
				height: 70rpx;
				position: absolute; //绝对定位
				bottom: 0; //左下角
				left: 0;
				background: rgba(0, 0, 0, 0.2);
				color: #fff;
				display: flex;
				align-items: center;
				justify-content: center;
				backdrop-filter: blur(20rpx); //模糊
				font-weight: 600;
				font-size: 30rpx;
			}

			.tab {
				position: absolute;
				left: 0;
				top: 0;
				background: rgba(250, 129, 90, 0.7);
				backdrop-filter: blur(20rpx);
				color: #fff;
				font-size: 22rpx;
				padding: 6rpx 14rpx;
				border-radius: 0 0 20rpx 0;
			}
		}
	}
</style>